package com.ft.model.enums;

import lombok.Getter;

/**
 * @author: zhangjianghua
 * @Date: 2018-10-09 16:56
 */
@Getter
public enum OrderStatusEnum {
    /**
     * 待支付，待发货，待收货，订单结束
      */
    WAIT_PAYMENT(1,"待支付"),
    WAIT_DELIVER(2,"待发货"),
    WAIT_RECEIVE(3,"待收货"),
    FINISH(4,"订单结束");

    private final Integer id;
    private String desc;

    OrderStatusEnum(Integer id, String desc){
        this.id = id;
        this.desc = desc;
    }
    public static OrderStatusEnum fromById(Integer id) {
        for (OrderStatusEnum mode: values()){
            if(mode.getId().equals(id)){
                return mode;

            }
        }
        throw new UnsupportedOperationException(
                "Enum conversion failed: the id " + id + " is not supported!"
        );
    }
}
